package com.lzy.crm.wechat.consts;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.support.AbstractBeanFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

/**
 * 微信参量类
 * @author chenshiping
 *
 */
//@Lazy(false)
//@Component
public class WechatPayProperties {
	
	private static final Logger logger = LogManager.getLogger(WechatPayProperties.class);
	
	
	@Resource
	private AbstractBeanFactory beanFactory;
	
	
	private static String partnerKey;
	
	
	private static String partnerId;
	
	
	private static String notify_url;
	
	// 公众平台的
	private static String appId;
	
	private static String token;
	// 
	private static String appSecret;
	
	// 开放平台的
	private static String openAppId;
	
	private static String openAppSecret;
	
	
	private static String redirectUri;
	
	// wechat.pay.channel
	// 代理分成比例
	private static String channel;
	
	private static String menuUrl;
	
	
	// 获取access_token的接口地址（GET）   
	private static String accessTokenUrl;
	// 获取 ticket 接口地址
	private static String jsapiTicketUrl;
	
	// 微信创建订单接口
	private static String createOrderUrl;
	
	// 图片装换接口
	private static String fileImgUrl;
	
	// 代理商充值分成比例
	private static String agentChannel;
	
	// 代理商购买
	private static String agentPay;
	
	
	private static String inviteUrl ;
	
	@PostConstruct
	public void init() {
		
		
		partnerKey = beanFactory.resolveEmbeddedValue("${wechat.pay.partnerKey}");
		
		
		partnerId = beanFactory.resolveEmbeddedValue("${wechat.pay.partnerId}");
		
		notify_url = beanFactory.resolveEmbeddedValue("${wechat.pay.notify_url}");
		
		appId  = beanFactory.resolveEmbeddedValue("${wechat.pay.appId}");
		
		
		appSecret = beanFactory.resolveEmbeddedValue("${wechat.pay.appSecret}");
		
		accessTokenUrl = beanFactory.resolveEmbeddedValue("${wechat.pay.access_token_url}");
		
		jsapiTicketUrl = beanFactory.resolveEmbeddedValue("${wechat.pay.jsapi_ticket_url}");
		
		createOrderUrl = beanFactory.resolveEmbeddedValue("${wechat.pay.create_order_url}");
		
		fileImgUrl = beanFactory.resolveEmbeddedValue("${wechat.pay.file_img_url}");
		
		token = beanFactory.resolveEmbeddedValue("${wechat.pay.token}");
		
		redirectUri = beanFactory.resolveEmbeddedValue("${wechat.pay.redirect_uri}");
		
		channel = beanFactory.resolveEmbeddedValue("${wechat.pay.channel}");
		
		
		menuUrl = beanFactory.resolveEmbeddedValue("${wechat.pay.menu_url}");
		
		agentChannel = beanFactory.resolveEmbeddedValue("${wechat.pay.agent_channel}");
		
		agentPay = beanFactory.resolveEmbeddedValue("${wechat.pay.agent_pay}");
		
		inviteUrl=beanFactory.resolveEmbeddedValue("${wechat.pay.invite_url}");
		
		
		openAppId  = beanFactory.resolveEmbeddedValue("${wechat.open.appId}");
		
		
		openAppSecret = beanFactory.resolveEmbeddedValue("${wechat.open.appSecret}");
		
		logger.info("init -> partnerKey -> {}", partnerKey);
		
		logger.info("init -> partnerId -> {}", partnerId);
		
		logger.info("init -> appId -> {}", appId);
		
		logger.info("init -> notify_url -> {}", notify_url);
		
		logger.info("init -> appSecret -> {}", appSecret);
		
		logger.info("init -> access_token_url -> {}", accessTokenUrl);
		
		logger.info("init -> jsapi_ticket_url -> {}", jsapiTicketUrl);
		
		logger.info("init -> create_order_url -> {}", createOrderUrl);
		
		logger.info("init -> fileImgUrl -> {}", fileImgUrl);
		
		logger.info("微信配置初始化完毕");
		
	}
	
	
	public static String getPartnerKey() {
		return partnerKey;
	}

	public static void setPartnerKey(String partnerKey) {
		WechatPayProperties.partnerKey = partnerKey;
	}

	public static String getPartnerId() {
		return partnerId;
	}

	public static void setPartnerId(String partnerId) {
		WechatPayProperties.partnerId = partnerId;
	}

	public static String getNotify_url() {
		return notify_url;
	}

	public static void setNotify_url(String notify_url) {
		WechatPayProperties.notify_url = notify_url;
	}

	public static String getAppId() {
		return appId;
	}

	public static void setAppId(String appId) {
		WechatPayProperties.appId = appId;
	}

	public static String getAppSecret() {
		return appSecret;
	}

	public static void setAppSecret(String appSecret) {
		WechatPayProperties.appSecret = appSecret;
	}


	public static String getAccessTokenUrl() {
		return accessTokenUrl;
	}

	public static void setAccessTokenUrl(String accessTokenUrl) {
		WechatPayProperties.accessTokenUrl = accessTokenUrl;
	}

	public static String getJsapiTicketUrl() {
		return jsapiTicketUrl;
	}

	public static void setJsapiTicketUrl(String jsapiTicketUrl) {
		WechatPayProperties.jsapiTicketUrl = jsapiTicketUrl;
	}
	
	public static String getCreateOrderUrl() {
		return createOrderUrl;
	}
	
	public static void setCreateOrderUrl(String createOrderUrl) {
		WechatPayProperties.createOrderUrl = createOrderUrl;
	}


	public static String getFileImgUrl() {
		return fileImgUrl;
	}


	public static void setFileImgUrl(String fileImgUrl) {
		WechatPayProperties.fileImgUrl = fileImgUrl;
	}


	public static String getToken() {
		return token;
	}


	public static void setToken(String token) {
		WechatPayProperties.token = token;
	}


	public static String getRedirectUri() {
		return redirectUri;
	}


	public static void setRedirectUri(String redirectUri) {
		WechatPayProperties.redirectUri = redirectUri;
	}


	public static String getChannel() {
		return channel;
	}


	public static void setChannel(String channel) {
		WechatPayProperties.channel = channel;
	}


	public static String getMenuUrl() {
		return menuUrl;
	}


	public static void setMenuUrl(String menuUrl) {
		WechatPayProperties.menuUrl = menuUrl;
	}


	public static String getAgentChannel() {
		return agentChannel;
	}


	public static void setAgentChannel(String agentChannel) {
		WechatPayProperties.agentChannel = agentChannel;
	}


	public static String getAgentPay() {
		return agentPay;
	}


	public static void setAgentPay(String agentPay) {
		WechatPayProperties.agentPay = agentPay;
	}


	public static String getInviteUrl() {
		return inviteUrl;
	}


	public static void setInviteUrl(String inviteUrl) {
		WechatPayProperties.inviteUrl = inviteUrl;
	}


	public static String getOpenAppId() {
		return openAppId;
	}

	public static void setOpenAppId(String openAppId) {
		WechatPayProperties.openAppId = openAppId;
	}

	public static String getOpenAppSecret() {
		return openAppSecret;
	}

	public static void setOpenAppSecret(String openAppSecret) {
		WechatPayProperties.openAppSecret = openAppSecret;
	}

	
}
